package com.study.whyyy.controller;

import cn.hutool.core.date.DateTime;
import com.study.whyyy.annotations.IdempotentAnnotation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author whyyy
 * @create 2025/2/13 14:12
 */

@Slf4j
@RestController
public class IdempotenController {
    /**
     * 测试
     *
     * @param orderId 假设orderId是从客户端传来的唯一标识订单请求的参数
     * @return 业务处理后字符串
     */
    @IdempotentAnnotation(requestId = "orderId")
    @PostMapping("/order")
    public String placeOrder(@RequestParam("orderId") String orderId) {
        //业务处理逻辑部分
        return DateTime.now().toString();
    }
}
